package com.cyrusInnovation.test.record;

/**
 * @author Al
 * 
 */
public enum Gender implements Comparable<Gender> {
	FEMALE("Female", "F"), MALE("Male", "M"), UNKNOWN("Unknown", "U");

	private String abbr;

	private String name;

	Gender(String name, String abbr) {
		this.name = name;
		this.abbr = abbr;
	}

	public String getName() {
		return name;
	}

	public String getAbbr() {
		return abbr;
	}

	// get gender from a string
	public static Gender fromString(String str) {
		for (Gender gender : Gender.values()) {
			if (str.equalsIgnoreCase(gender.getName())) {
				return gender;
			}
			if (str.equalsIgnoreCase(gender.getAbbr())) {
				return gender;
			}
		}
		return UNKNOWN;
	}

	@Override
	public String toString() {
		return getName();
	}

}
